﻿using DataAccess;
using DTO;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAO
{
    public class DonViTinhDAO
    {
        public static List<DonViTinhDTO> LoadDanhSachDonVi()
        {
            List<DonViTinhDTO> list = new List<DonViTinhDTO>();
            string sql = "SELECT * FROM DonViTinh";
            DataTable kq = DataConnection.ExecQuery(sql);
            if (kq.Rows.Count > 0)
            {
                for (int i = 0; i < kq.Rows.Count; i++)
                {
                    DataRow dr = kq.Rows[i];
                    DonViTinhDTO dd = new DonViTinhDTO();
                    dd.MaDonVi = Convert.ToInt32(dr["MaDonViTinh"]);
                    dd.TenDonVi = dr["TenDonViTinh"].ToString();
                    list.Add(dd);
                }
            }
            return list;
        }
    }
}
